package com.per.demobeetlsql.service;

import com.per.demobeetlsql.dao.EmpDao;
import com.per.demobeetlsql.dao.TTestDao;
import com.per.demobeetlsql.entity.Emp;
import com.per.demobeetlsql.entity.TTest;
import org.beetl.sql.core.SQLManager;
import org.beetl.sql.core.db.DBStyle;
import org.beetl.sql.core.db.SqlServer2012Style;
import org.beetl.sql.core.mapper.MapperBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Cheng
 * @date 2020/9/24 15:11
 */
@Service
public class DataService {

    @Autowired
    private EmpDao empDao;

    @Autowired
    private TTestDao tTestDao;

    public List<Emp> getAllEmp(String datasource) {
        return empDao.all();
    }

    public List<TTest> getAll(String datasource) {
        DBStyle dbStyle = new SqlServer2012Style();
        SQLManager sqlManager = tTestDao.getSQLManager();
        SQLManager temp = new SQLManager(dbStyle, sqlManager.getDs());
        return temp.all(TTest.class);
        //return tTestDao.all();
    }
}
